<?php
/**
 * Sharings View for Sharing World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4
 * @license		GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
 * Sharings View
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class CongregationViewProvinces extends CongregationView
{
	protected $items;
	protected $pagination;
	protected $state;
	/**
	 * Sharings view display method
	 * @return void
	 **/
	function display($tpl = null)
	{
		
		$this->state		= $this->get('State');
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		foreach ($this->items as &$item) {
			$item->order_up = true;
			$item->order_dn = true;
		}
		$this->addToolbar();
		parent::display($tpl);
	}
	
	
		/**
	 * Add the page title and toolbar.
	 *
	 * @since	1.6
	 */
	protected function addToolbar()
	{
		require_once JPATH_COMPONENT.'/helpers/congregation.php';

		$state	= $this->get('State');
		$canDo	= CongregationHelper::getActions();
		$user	= JFactory::getUser();

		JToolBarHelper::title(JText::_('Province Manager'), 'weblinks.png');
		if ($canDo->get('core.create')) {
			JToolBarHelper::addNew('province.add');
		}
		if ($canDo->get('core.edit')) {
			JToolBarHelper::editList('province.edit', 'JTOOLBAR_EDIT');
		}

		if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
			JToolBarHelper::deleteList('', 'province.delete', 'JTOOLBAR_EMPTY_TRASH');
			JToolBarHelper::divider();
		} elseif ($canDo->get('core.edit.state')) {
			JToolBarHelper::trash('province.trash');
		}

	}
	

}
